Repository navigation
Sync python-import with the updated tutorial - #894
Open
realpython-bot wants to merge 1 commit into
Open
realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
…nced Techniques and Tips - population_quiz.py: pass list(population) to random.sample(), which no longer accepts dict views (Python 3.11+) - plugins.py: replace deprecated importlib.resources.contents() with files().iterdir() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Companion to the maintenance update of Python import: Advanced Techniques and Tips.
What changed
population_quiz/population_quiz.py:random.sample(population.keys(), ...)raisesTypeError: Population must be a sequencesince Python 3.11. It now passeslist(population).plugins.py:importlib.resources.contents()is deprecated since Python 3.11._import_all()now lists files withresources.files(package).iterdir(), matching the updated article.Links
Verification (Python 3.14.6)
import greeter; greeter.greetings()returns['hello', 'howdy', 'yo']andgreeter.greet("howdy", "Guido")works with-W error(no DeprecationWarning).population_quiz.pyran through several questions against a stub CSV (the real UN WPP2019 file is no longer downloadable, tracked on the card as a full-update item).uvx ruff@0.14.1 format --check python-importanduvx ruff@0.14.1 check python-importpass.Note:
population_quiz/data/README.mdstill points at the retired WPP2019 download. Switching to WPP2024 is left for the full update.🤖 Generated with Claude Code